package com.wanxi.servlet;

import javax.servlet.*;
import javax.servlet.annotation.WebServlet;
import java.io.IOException;

@WebServlet("/demo")
public class ServletDemo implements Servlet {
//    初始化：一般只执行一次
    @Override
    public void init(ServletConfig servletConfig) throws ServletException {
        System.out.println("init");
    }

//    配置：配置类
    @Override
    public ServletConfig getServletConfig() {
        System.out.println("getServletConfig");
        return null;
    }

//    服务：重点：每次访问都会经过service
    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
        System.out.println("service");
    }

//    得到servlet的信息
    @Override
    public String getServletInfo() {
        System.out.println("getServletInfo");
        return null;
    }

//    销毁：程序执行完后正常销毁，
    @Override
    public void destroy() {
        System.out.println("destroy");
    }
}
